//
//  ZYLSigleCollectionViewCell.m
//  Cartoon
//
//  Created by dllo on 15/7/16.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "ZYLSigleCollectionViewCell.h"
#import "UIImageView+WebCache.h"
@implementation ZYLSigleCollectionViewCell
- (void)dealloc
{
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.mainImage = [[[UIImageView alloc] init] autorelease];
        self.mainImage.backgroundColor = [UIColor greenColor];
        [self.contentView addSubview:self.mainImage];
        self.backView = [[[UIView alloc] init] autorelease];
        [self.contentView addSubview:self.backView];
        self.title = [[[UILabel alloc] init] autorelease];
        [self.backView addSubview:self.title];
        self.name = [[[UILabel alloc] init] autorelease];
        [self.backView addSubview:self.name];
    }
    return self;
}

- (void)setComicModel:(ZYLComicModel *)comicModel
{
    if (_comicModel != comicModel) {
        [_comicModel release];
        [_comicModel retain];
    }
    [self.mainImage sd_setImageWithURL:[NSURL URLWithString:comicModel.cover_image_url]];
    self.title.text = comicModel.title;
    self.name.text = comicModel.model.searchnickname;
}



- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.mainImage.frame = CGRectMake(0, 0, layoutAttributes.size.width, layoutAttributes.size.height / 10 * 7);
    self.backView.frame = CGRectMake(0, layoutAttributes.size.height / 10 * 7, layoutAttributes.size.width, layoutAttributes.size.height / 10 * 3);
    self.title.frame = CGRectMake(0, 0, self.backView.frame.size.width, self.backView.frame.size.height / 2);
    self.name.frame = CGRectMake(0, self.backView.frame.size.height / 2, self.backView.frame.size.width, self.backView.frame.size.height / 2);
}
@end
